package com.example.demo.ai.check;

import com.example.demo.ai.upload.UploadImageDriService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class CheckController {

    @Autowired
    private CheckService checkService;

    @PostMapping("/api/check")
    public ResponseEntity<String> uploadFolderToSsh(@RequestParam("pyPath") String pyPath,
                                                    @RequestParam("file") String file) {
        try {
            String path = checkService.executeRemoteCommand(file,pyPath);
            return ResponseEntity.ok("检测成功: " + path);
        } catch (Exception e) {
            return ResponseEntity.badRequest().body("检测失败: " + e.getMessage());
        }
    }
}
